<?php

namespace app\webapi\vms\validate;

use app\webapi\common\BaseValidate;

/**
 * @分类验证类
 */
class CategoryValidate extends BaseValidate
{
    //验证规则
    protected $rule = [
        'page_no' => 'require|number',
        'page_size' => 'require|number',
        'pid' => 'require|number',
        'name' => 'require|length:2,64',
        'type' => 'in:1,2',
        'seo_title' => 'length:0,32',
        'seo_keywords' => 'length:0,128',
        'seo_desc' => 'length:0,2048',
        'page_limit' => 'number',
    ];

    //验证消息
    protected $message = [
        'page_no.require' => '页码必填',
        'page_no.number' => '页码参数必须是整数类型',
        'page_size.require' => '每页显示条目数必填',
        'page_size.number' => '每页显示条目数必须是整数类型',
        'pid.require' => '父级id必填',
        'pid.number' => '父级id必须是整数类型',
        'name.require' => '名称必填',
        'name.length' => '名称长度为2-64个字符',
        'type.in' => 'type可选值为1,2',
        'seo_title.length' => 'seo标题长度为0-32个字符',
        'seo_keywords.length' => 'seo关键字长度为0-128个字符',
        'seo_desc.length' => 'seo描述长度为0-2048个字符',
        'page_limit.number' => '每页显示条目数必须是整数类型',
    ];

    //验证场景
    protected $scene = [
        'getTreeList' => [''],
        'edit' => ['name', 'pid', 'seo_title', 'seo_keywords', 'seo_desc', 'page_limit'],
        'delete' => ['id'],
        'sort' => ['pid'],
    ];

}